/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/

// JIT.cpp : 定义静态库的函数。
//

#include "pch.h"
#include "framework.h"

#include "JIT.h"
#include "LLVM/LLVM_JIT.h"

#include "词法分析/词法.h"

#include <字符串转换.h>
#include <Windows.h>


/*
LLVMCore.lib
LLVMExecutionEngine.lib
LLVMInterpreter.lib
LLVMMC.lib
LLVMMCJIT.lib
LLVMSupport.lib
LLVMX86CodeGen.lib
LLVMX86Desc.lib
LLVMX86Info.lib
LLVMOrcTargetProcess.lib
LLVMOrcShared.lib
LLVMRuntimeDyld.lib
LLVMMCDisassembler.lib
LLVMAsmPrinter.lib
LLVMDebugInfoDWARF.lib
LLVMDebugInfoMSF.lib
LLVMInstrumentation.lib
LLVMGlobalISel.lib
LLVMSelectionDAG.lib
LLVMCodeGen.lib
LLVMTarget.lib
LLVMScalarOpts.lib
LLVMAggressiveInstCombine.lib
LLVMInstCombine.lib
LLVMTransformUtils.lib
LLVMAnalysis.lib
LLVMObject.lib
LLVMMCParser.lib
LLVMDebugInfoCodeView.lib
LLVMTextAPI.lib
LLVMProfileData.lib
LLVMCFGuard.lib
LLVMBinaryFormat.lib
LLVMRemarks.lib
LLVMOrcJIT.lib
LLVMX86AsmParser.lib
LLVMX86Desc.lib
LLVMX86Disassembler.lib
LLVMPasses.lib
LLVMCoroutines.lib
LLVMipo.lib
LLVMFrontendOpenMP.lib
LLVMIRReader.lib
LLVMAsmParser.lib
LLVMLinker.lib
LLVMObjCARCOpts.lib
LLVMVectorize.lib
LLVMJITLink.lib
LLVMCodeGen.lib
LLVMDemangle.lib
LLVM-C.lib


LLVMAArch64CodeGen.lib
LLVMAArch64AsmParser.lib
LLVMAArch64Desc.lib
LLVMAArch64Disassembler.lib
LLVMAArch64Utils.lib
LLVMAArch64Info.lib

LLVMAMDGPUAsmParser.lib
LLVMAMDGPUCodeGen.lib
LLVMAMDGPUDesc.lib
LLVMAMDGPUTargetMCA.lib
LLVMAMDGPUDisassembler.lib
LLVMAMDGPUInfo.lib
LLVMAMDGPUUtils.lib

LLVMARMCodeGen.lib
LLVMARMAsmParser.lib
LLVMARMDesc.lib
LLVMARMDisassembler.lib
LLVMARMInfo.lib
LLVMARMUtils.lib
LLVMAVRCodeGen.lib
LLVMAVRAsmParser.lib
LLVMAVRDesc.lib
LLVMAVRDisassembler.lib
LLVMAVRInfo.lib
LLVMNVPTXInfo.lib
LLVMNVPTXCodeGen.lib
LLVMNVPTXDesc.lib

LLVMBPFAsmParser.lib
LLVMBPFCodeGen.lib
LLVMBPFDesc.lib
LLVMBPFDisassembler.lib
LLVMBPFInfo.lib
LLVMHexagonAsmParser.lib
LLVMHexagonCodeGen.lib
LLVMHexagonDesc.lib
LLVMHexagonDisassembler.lib
LLVMHexagonInfo.lib

LLVMMipsAsmParser.lib
LLVMMipsCodeGen.lib
LLVMMipsDesc.lib
LLVMMipsDisassembler.lib
LLVMMipsInfo.lib

LLVMPowerPCAsmParser.lib
LLVMPowerPCCodeGen.lib
LLVMPowerPCDesc.lib
LLVMPowerPCDisassembler.lib
LLVMPowerPCInfo.lib

LLVMBinaryFormat.lib
LLVMBitReader.lib
LLVMBitstreamReader.lib
LLVMBitWriter.lib

LLVMXCoreCodeGen.lib
LLVMXCoreDesc.lib
LLVMXCoreDisassembler.lib
LLVMXCoreInfo.lib

LLVMWebAssemblyAsmParser.lib
LLVMWebAssemblyCodeGen.lib
LLVMWebAssemblyDesc.lib
LLVMWebAssemblyDisassembler.lib
LLVMWebAssemblyInfo.lib
LLVMWebAssemblyUtils.lib

LLVMSystemZAsmParser.lib
LLVMSystemZCodeGen.lib
LLVMSystemZDesc.lib
LLVMSystemZDisassembler.lib
LLVMSystemZInfo.lib

LLVMLanaiAsmParser.lib
LLVMLanaiCodeGen.lib
LLVMLanaiDesc.lib
LLVMLanaiDisassembler.lib
LLVMLanaiInfo.lib

LLVMMSP430AsmParser.lib
LLVMMSP430CodeGen.lib
LLVMMSP430Desc.lib
LLVMMSP430Disassembler.lib
LLVMMSP430Info.lib

LLVMRISCVAsmParser.lib
LLVMRISCVCodeGen.lib
LLVMRISCVDesc.lib
LLVMRISCVDisassembler.lib
LLVMRISCVInfo.lib
LLVMRISCVUtils.lib

LLVMSparcAsmParser.lib
LLVMSparcCodeGen.lib
LLVMSparcDesc.lib
LLVMSparcDisassembler.lib
LLVMSparcInfo.lib

LLVMExegesis.lib
LLVMExegesisAArch64.lib
LLVMExegesisMips.lib
LLVMExegesisPowerPC.lib
LLVMExegesisX86.lib
LLVMExtensions.lib

LLVMOrcError.lib
LLVMOrcJIT.lib
LLVMOrcShared.lib
LLVMOrcTargetProcess.lib

*/


/*#ifdef _DEBUG 




#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBinaryFormat.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBitReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBitstreamReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBitWriter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBPFAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBPFCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBPFDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBPFDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMBPFInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVM-C.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMCFGuard.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMCFIVerify.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMCore.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMCoroutines.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMCoverage.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDebugInfoCodeView.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDebugInfoDWARF.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDebugInfoGSYM.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDebugInfoMSF.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDebugInfoPDB.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDemangle.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDlltoolDriver.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDWARFLinker.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMExecutionEngine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMExegesis.lib")
//#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMExegesisAArch64.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMExegesisX86.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMExtensions.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMFileCheck.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMFrontendOpenACC.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMFrontendOpenMP.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMFuzzMutate.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMGlobalISel.lib")
//#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMHexagonAsmParser.lib")
//#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMHexagonCodeGen.lib")
//#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMHexagonDesc.lib")
//#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMHexagonDisassembler.lib")
//#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMHexagonInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMInstCombine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMInstrumentation.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMInterfaceStub.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMInterpreter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMipo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMIRReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMLinker.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMLanaiAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMLanaiCodeGen.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMLTO.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMMC.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMMCA.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMMCDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMMCJIT.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMMCParser.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMNVPTXCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMNVPTXDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMNVPTXInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMObjCARCOpts.lib")



#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMAggressiveInstCombine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMAnalysis.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMAsmPrinter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMAVRAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMAVRCodeGen.lib")






#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMXCoreCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMMCParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMMC.lib")




#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDemangle.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMDlltoolDriver.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMRuntimeDyld.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMInterpreter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMInstrumentation.lib")


#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMObjCARCOpts.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMObject.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMOption.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMOrcJIT.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMOrcShared.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMOrcTargetProcess.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMPasses.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMProfileData.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMRemarks.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMScalarOpts.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSelectionDAG.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSparcAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSparcCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSparcDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSparcDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSparcInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSupport.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSymbolize.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSystemZAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSystemZCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSystemZDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSystemZDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMSystemZInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMTableGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMTableGenGlobalISel.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMTarget.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMTextAPI.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMTransformUtils.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMVectorize.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMX86AsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMX86CodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMX86Desc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMX86Disassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMX86Info.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMXCoreCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMXCoreDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMXCoreDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMXCoreInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMXRay.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LTO.lib")
#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/Remarks.lib")

#pragma comment(lib, "D:/U/DEV/llvm/debug/lib/LLVMJITLink.lib")



#else


#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBinaryFormat.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBitReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBitstreamReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBitWriter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBPFAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBPFCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBPFDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBPFDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBPFInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVM-C.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCFGuard.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCFIVerify.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCore.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCoroutines.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCoverage.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoCodeView.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoDWARF.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoGSYM.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoMSF.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoPDB.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDemangle.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDlltoolDriver.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDWARFLinker.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMExecutionEngine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMExegesis.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMExegesisAArch64.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMExegesisX86.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMExtensions.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMFileCheck.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMFrontendOpenACC.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMFrontendOpenMP.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMFuzzMutate.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMGlobalISel.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMHexagonAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMHexagonCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMHexagonDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMHexagonDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMHexagonInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInstCombine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInstrumentation.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInterfaceStub.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInterpreter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMipo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMIRReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMLinker.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMLanaiAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMLanaiCodeGen.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMLTO.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMC.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMCA.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMCDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMCJIT.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMCParser.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMNVPTXCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMNVPTXDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMNVPTXInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMObjCARCOpts.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAggressiveInstCombine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAnalysis.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAsmPrinter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAVRAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAVRCodeGen.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMXCoreCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMCJIT.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMCParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMC.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDemangle.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDlltoolDriver.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMRuntimeDyld.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInterpreter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInstrumentation.lib")
									
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMObjCARCOpts.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMObject.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMOption.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMOrcJIT.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMOrcShared.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMOrcTargetProcess.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMPasses.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMProfileData.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMRemarks.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMScalarOpts.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSelectionDAG.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSparcAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSparcCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSparcDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSparcDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSparcInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSupport.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSymbolize.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSystemZAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSystemZCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSystemZDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSystemZDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSystemZInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTableGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTableGenGlobalISel.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTarget.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTextAPI.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTransformUtils.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMVectorize.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMX86AsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMX86CodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMX86Desc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMX86Disassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMX86Info.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMXCoreCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMXCoreDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMXCoreDisassembler.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMXCoreInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMXRay.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LTO.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/Remarks.lib")
									
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMJITLink.lib")




#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAMDGPUCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAMDGPUDesc.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAMDGPUInfo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCodeGen.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCore.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMC.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSupport.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/gtest_main.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/gtest.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAsmPrinter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoDWARF.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoMSF.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMPasses.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMCoroutines.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMipo.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMFrontendOpenMP.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMIRReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMLinker.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInstrumentation.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMObjCARCOpts.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAMDGPUUtils.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMVectorize.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMGlobalISel.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMSelectionDAG.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMIRParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMScalarOpts.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAggressiveInstCombine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMInstCombine.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTransformUtils.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBitWriter.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTarget.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAnalysis.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMProfileData.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMObject.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBitReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMMCParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMDebugInfoCodeView.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMTextAPI.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMAsmParser.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMRemarks.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBitstreamReader.lib")
#pragma comment(lib, "D:/U/DEV/llvm/Release/lib/LLVMBinaryFormat.lib")


#endif*/





static std::map<uint64, C_程序代码*> g_程序集容器;
//static std::set<C_程序代码*> g_程序集容器;
//std::set<llvm::ExecutionEngine*> g执行引擎;




// TODO: 这是一个库函数示例
void fnJIT() {

}









bool f_init_JTI() {
	f_llvm_初始化JIT引擎();
	//f_llvm_构建机器码();
	return false;
}

bool f_close_JIT() {
	f_llvm_清理JIT引擎();
	return false;
}

uint64 f_JIT_加载代码(std::string path, E_JIT方式 方式) {
	switch (方式) {
	case E_JIT方式::e_jit_llvm: {
		uint64 ee = (uint64)f_llvm_创建程序集(path);
		//g执行引擎.insert(ee);
		return (uint64)ee;
	}
	case E_JIT方式::e_jit_dll: {
		auto* ee = LoadLibraryA(path.c_str());
		//auto* ee = LoadLibraryW(p.c_str());
		return (uint64)ee;
	}
	}
	return 0;
}

uint64 f_JIT_取函数指针(uint64 模块名称, std::string 函数名称, E_JIT方式 方式) {
	if (函数名称.empty()) return 0;

	switch (方式) {
	case E_JIT方式::e_jit_llvm: {
		//llvm::ExecutionEngine* ee = *g执行引擎.find((llvm::ExecutionEngine*)模块名称);
		return f_llvm_从程序集取函数指针(函数名称);
	}
	case E_JIT方式::e_jit_dll: {
		//auto name = f_String转码(函数名称, "utf-8");
		auto name = 函数名称;
		return (uint64)GetProcAddress((HMODULE)模块名称, name.c_str());
	}
	}

	return 0;
}

void f_JIT_运行(uint64 函数指针) {
}

bool f_JIT_运行(uint64 执行引擎, std::string 函数名称, std::vector<E_JIT_FunParam>& 参数) {
	//llvm::ExecutionEngine* ee = *g执行引擎.find((llvm::ExecutionEngine*)执行引擎);
	//return f_llvm_执行函数(函数名称, ee, 参数);
	return false;
}

void f_JIT_销毁(uint64 执行引擎, E_JIT方式 方式) {
	switch (方式) {
	case E_JIT方式::e_jit_llvm: {
		f_llvm_销毁程序集((llvm::Module*)执行引擎);
		//llvm::ExecutionEngine* ee = (llvm::ExecutionEngine*)执行引擎;
		//if (g执行引擎.find(ee) != g执行引擎.end()) {
		//	delete ee;
		//	g执行引擎.erase(ee);
		//}
		break;
	}
		
	case E_JIT方式::e_jit_dll: {
		FreeLibrary((HMODULE)执行引擎);
	}
	default:
		break;
	}
	
}

void f_JIT_添加全局变量(const std::vector<std::string>& 全局变量名称, const std::vector<E_JIT_FunParam>& 函数指针) {
	uint32 num = 全局变量名称.size();
	for (uint32 i = 0; i < num; ++i) {
		f_llvm_添加全局变量(全局变量名称[i], (uint64)函数指针[i].m_data);
	}
}




uint64 f_JIT_创建代码块() {
	C_程序代码* code = new C_程序代码();
	g_程序集容器[(uint64)code] = code;

	return (uint64)code;
}

void f_JIT_编译代码(uint64 程序集KEY, std::wstring code) {
	if (g_程序集容器.find(程序集KEY) != g_程序集容器.end()) {
		g_程序集容器[程序集KEY]->f_Load代码(code);
	}
}

void f_JIT_卸载程序(uint64 程序集KEY) {
}



void f_JIT_get函数声明(uint64 程序集KEY, std::vector<S_类型名称>& 输入参数, std::vector<S_类型名称>& 输出参数) {
	if (g_程序集容器.find(程序集KEY) != g_程序集容器.end()) {
		if (g_程序集容器[程序集KEY]->m_程序树.m_子树.size()) {
			for (auto& e : g_程序集容器[程序集KEY]->m_程序树.m_子树) {
				输入参数 = e.second->m_in参数类型;
				输出参数 = e.second->m_out参数类型;
			}
			//输入参数 = g_程序集容器[程序集KEY]->m_程序树.m_子树[0]->m_in参数类型;
			//输出参数 = g_程序集容器[程序集KEY]->m_程序树.m_子树[0]->m_out参数类型;
		}
		
	}
}








